<?php
class Login extends CI_Controller {
	public function index() {
		$this->template->write_view ( 'left', 'front_end/layout/left', null, TRUE );
		$this->template->write_view ( 'center', 'front_end/login/index', null, TRUE );
	/*	$this->template->write_view('right','front_end/news/news_right',null,TRUE);*/
		$this->template->write_view('menu_footer','front_end/layout/menu_footer',null,TRUE);
		$this->template->write_view ( 'menu', 'front_end/layout/menu', null, TRUE );
		$this->template->load ();
	}
	public function login_username() {
		/*$this->form_validation->set_rules( 'username', 'username', 'trim|required' );
		if ($this->form_validation->run () == FALSE) {
			redirect ( 'login' );
		} else {
			$u = $_GET ['username'];
			$p = $_GET ['password'];
			if ($this->User_model->validate_login ( $u, $p )) {
				redirect ( 'home' );
			}
			else {
			echo 'a';
			}
		}*/
		
		$u = $_GET ['username'];
		$p = $_GET ['password'];
		if ($this->User_model->validate_login ( $u, $p )) {
			redirect ( 'home' );
		} else {
			redirect ( 'error' );
		}
	
	}
	public function logout()
	{
		 $this->session->unset_userdata('username');
		$this->template->write_view('left','front_end/layout/left',null,TRUE);
		$this->template->write_view('center','front_end/home/index',null,TRUE);
		$this->template->write_view('right','front_end/layout/right',null,TRUE);
		$this->template->write_view('menu','front_end/layout/menu',null,TRUE);
		$this->template->write_view('menu_footer','front_end/layout/menu_footer',null,TRUE);
		$this->template->load();
		 
	}
}
